<?
##########################################################################
#		DOCUMENTATION
##########################################################################
# Class that extends the rootclass. This module will provide the methods
# needed to render the profile page.
#
# © LiberLab group, 2011
##########################################################################

require_once("base/sendData.php");
require_once("dataStructure/user.php");

class Renderer extends SendData{
	public function __construct() {
		parent::__construct("profile", "profile");
	}
	
	public function profileRender(){
		$userClass = new User();
		$nickname = $this->getSession("nickname");
		# the 1 is to tell the login that the password is already encrypted
		$login = $userClass->login($nickname, $this->getSession("password"), 1);
		if ($nickname){
			$userData = $userClass->getUserData($nickname);
			$this->tagHash["nickname"] = ucfirst($userData->nickname);
			$this->tagHash["email"] = $userData->email;
			$this->tagHash["registrationData"] = $userData->registrationData;
			if ($userData->admin == 1){
				$this->tagHash["admin"] = $this->messages["yes"];
			}else{
				$this->tagHash["admin"] = $this->messages["no"];
			}
			$this->tagHash["authorName"] = $userData->name;
			$this->tagHash["authorSurname"] = $userData->surname;
			return 1;
		}else{
			return 0;
		}
	}
	
	public function main(){
		$noUser = getParam("no_user", "");
		$noPassword = getParam("no_password", "");
		$noMatch = getParam("no_match", "");
		$noValidEmail = getParam("no_email", "");
		$nicknameOver = getParam("nickname_over", "");
		$noLogin = getParam("no_login", "");
		$generic = getParam("generic", "");
		
		if (!$this->profileRender()){
			return $this->backOff(); # exit!
		}
		$this->renderHidden();
		$this->warnBoxManager(array("noUser" => $noUser, "noPassword" => $noPassword, "noMatch" => $noMatch, "noValidEmail" => $noValidEmail, 
									"nicknameOver" => $nicknameOver, "noLogin" => $noLogin, "generic" => $generic));
		return $this->render();
	}

	public function __destruct() {
		parent::__destruct();
	}
};

?>
